home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / emacs_src_18_58.lha / emacs-18.58 / cpp / cexp.tab.c < prev    next >
C/C++ Source or Header  |  1991-12-24  |  34KB  |  1,338 lines

  1.  
  2. /*  A Bison parser, made from cexp.y  */
  3.  
  4. #define    INT    258
  5. #define    CHAR    259
  6. #define    NAME    260
  7. #define    ERROR    261
  8. #define    OR    262
  9. #define    AND    263
  10. #define    EQUAL    264
  11. #define    NOTEQUAL    265
  12. #define    LEQ    266
  13. #define    GEQ    267
  14. #define    LSH    268
  15. #define    RSH    269
  16. #define    UNARY    270
  17.  
  18. #line 99 "cexp.y"
  19.  
  20. #include <setjmp.h>
  21. /* #define YYDEBUG 1 */
  22.  
  23.   static int yylex ();
  24.   static yyerror ();
  25.   int expression_value;
  26.  
  27.   static jmp_buf parse_return_error;
  28.  
  29.   /* some external tables of character types */
  30.   extern unsigned char is_idstart[], is_idchar[];
  31.  
  32.  
  33. #line 114 "cexp.y"
  34. typedef union {
  35.   long lval;
  36.   int voidval;
  37.   char *sval;
  38. } YYSTYPE;
  39.  
  40. #ifndef YYLTYPE
  41. typedef
  42.   struct yyltype
  43.     {
  44.       int timestamp;
  45.       int first_line;
  46.       int first_column;
  47.       int last_line;
  48.       int last_column;
  49.       char *text;
  50.    }
  51.   yyltype;
  52.  
  53. #define YYLTYPE yyltype
  54. #endif
  55.  
  56. #include <stdio.h>
  57.  
  58. #ifndef __STDC__
  59. #define const
  60. #endif
  61.  
  62.  
  63.  
  64. #define    YYFINAL        59
  65. #define    YYFLAG        -32768
  66. #define    YYNTBASE    33
  67.  
  68. #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 36)
  69.  
  70. static const char yytranslate[] = {     0,
  71.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  72.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  73.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  74.      2,     2,    27,     2,     2,     2,    25,    12,     2,    29,
  75.     30,    23,    21,     7,    22,     2,    24,     2,     2,     2,
  76.      2,     2,     2,     2,     2,     2,     2,    32,     2,    15,
  77.      2,    16,    31,     2,     2,     2,     2,     2,     2,     2,
  78.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  79.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  80.      2,     2,     2,    11,     2,     2,     2,     2,     2,     2,
  81.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  82.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  83.      2,     2,     2,    10,     2,    28,     2,     2,     2,     2,
  84.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  85.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  86.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  87.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  88.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  89.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  90.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  91.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  95.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  96.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  97.      6,     8,     9,    13,    14,    17,    18,    19,    20,    26
  98. };
  99.  
  100. static const short yyprhs[] = {     0,
  101.      0,     2,     4,     8,    11,    14,    17,    21,    25,    29,
  102.     33,    37,    41,    45,    49,    53,    57,    61,    65,    69,
  103.     73,    77,    81,    85,    89,    93,    99,   101,   103
  104. };
  105.  
  106. static const short yyrhs[] = {    34,
  107.      0,    35,     0,    34,     7,    35,     0,    22,    35,     0,
  108.     27,    35,     0,    28,    35,     0,    29,    34,    30,     0,
  109.     35,    23,    35,     0,    35,    24,    35,     0,    35,    25,
  110.     35,     0,    35,    21,    35,     0,    35,    22,    35,     0,
  111.     35,    19,    35,     0,    35,    20,    35,     0,    35,    13,
  112.     35,     0,    35,    14,    35,     0,    35,    17,    35,     0,
  113.     35,    18,    35,     0,    35,    15,    35,     0,    35,    16,
  114.     35,     0,    35,    12,    35,     0,    35,    11,    35,     0,
  115.     35,    10,    35,     0,    35,     9,    35,     0,    35,     8,
  116.     35,     0,    35,    31,    35,    32,    35,     0,     3,     0,
  117.      4,     0,     5,     0
  118. };
  119.  
  120. #if YYDEBUG != 0
  121. static const short yyrline[] = { 0,
  122.    140,   145,   146,   151,   153,   155,   157,   162,   164,   166,
  123.    168,   170,   172,   174,   176,   178,   180,   182,   184,   186,
  124.    188,   190,   192,   194,   196,   198,   200,   202,   204
  125. };
  126.  
  127. static const char * const yytname[] = {   "$",
  128. "error","$illegal.","INT","CHAR","NAME","ERROR","','","OR","AND","'|'",
  129. "'^'","'&'","EQUAL","NOTEQUAL","'<'","'>'","LEQ","GEQ","LSH","RSH",
  130. "'+'","'-'","'*'","'/'","'%'","UNARY","'!'","'~'","'('","')'",
  131. "'?'","':'","start","exp1","exp",""
  132. };
  133. #endif
  134.  
  135. static const short yyr1[] = {     0,
  136.     33,    34,    34,    35,    35,    35,    35,    35,    35,    35,
  137.     35,    35,    35,    35,    35,    35,    35,    35,    35,    35,
  138.     35,    35,    35,    35,    35,    35,    35,    35,    35
  139. };
  140.  
  141. static const short yyr2[] = {     0,
  142.      1,     1,     3,     2,     2,     2,     3,     3,     3,     3,
  143.      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
  144.      3,     3,     3,     3,     3,     5,     1,     1,     1
  145. };
  146.  
  147. static const short yydefact[] = {     0,
  148.     27,    28,    29,     0,     0,     0,     0,     1,     2,     4,
  149.      5,     6,     0,     0,     0,     0,     0,     0,     0,     0,
  150.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  151.      0,     0,     0,     7,     3,    25,    24,    23,    22,    21,
  152.     15,    16,    19,    20,    17,    18,    13,    14,    11,    12,
  153.      8,     9,    10,     0,     0,    26,     0,     0,     0
  154. };
  155.  
  156. static const short yydefgoto[] = {    57,
  157.      8,     9
  158. };
  159.  
  160. static const short yypact[] = {    27,
  161. -32768,-32768,-32768,    27,    27,    27,    27,    -3,    74,   -28,
  162.    -28,   -28,    45,    27,    27,    27,    27,    27,    27,    27,
  163.     27,    27,    27,    27,    27,    27,    27,    27,    27,    27,
  164.     27,    27,    27,-32768,    74,    97,   119,    22,   139,   158,
  165.    175,   175,   188,   188,   188,   188,   193,   193,   197,   197,
  166.    -28,   -28,   -28,    49,    27,    74,     5,     6,-32768
  167. };
  168.  
  169. static const short yypgoto[] = {-32768,
  170.      0,    -4
  171. };
  172.  
  173.  
  174. #define    YYLAST        228
  175.  
  176.  
  177. static const short yytable[] = {    10,
  178.     11,    12,    33,    14,    58,    59,    13,     0,     0,    35,
  179.     36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
  180.     46,    47,    48,    49,    50,    51,    52,    53,    54,     1,
  181.      2,     3,    18,    19,    20,    21,    22,    23,    24,    25,
  182.     26,    27,    28,    29,    30,    31,    32,     0,     4,     0,
  183.     56,    14,    33,     5,     6,     7,    15,    16,    17,    18,
  184.     19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
  185.     29,    30,    31,    32,    34,     0,     0,     0,     0,    33,
  186.     55,    15,    16,    17,    18,    19,    20,    21,    22,    23,
  187.     24,    25,    26,    27,    28,    29,    30,    31,    32,     0,
  188.      0,     0,     0,     0,    33,    16,    17,    18,    19,    20,
  189.     21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
  190.     31,    32,     0,     0,     0,     0,     0,    33,    17,    18,
  191.     19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
  192.     29,    30,    31,    32,     0,     0,     0,     0,     0,    33,
  193.     19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
  194.     29,    30,    31,    32,     0,     0,     0,     0,     0,    33,
  195.     20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
  196.     30,    31,    32,     0,     0,     0,     0,     0,    33,    22,
  197.     23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
  198.      0,     0,     0,     0,     0,    33,    26,    27,    28,    29,
  199.     30,    31,    32,    28,    29,    30,    31,    32,    33,    30,
  200.     31,    32,     0,    33,     0,     0,     0,    33
  201. };
  202.  
  203. static const short yycheck[] = {     4,
  204.      5,     6,    31,     7,     0,     0,     7,    -1,    -1,    14,
  205.     15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
  206.     25,    26,    27,    28,    29,    30,    31,    32,    33,     3,
  207.      4,     5,    11,    12,    13,    14,    15,    16,    17,    18,
  208.     19,    20,    21,    22,    23,    24,    25,    -1,    22,    -1,
  209.     55,     7,    31,    27,    28,    29,     8,     9,    10,    11,
  210.     12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
  211.     22,    23,    24,    25,    30,    -1,    -1,    -1,    -1,    31,
  212.     32,     8,     9,    10,    11,    12,    13,    14,    15,    16,
  213.     17,    18,    19,    20,    21,    22,    23,    24,    25,    -1,
  214.     -1,    -1,    -1,    -1,    31,     9,    10,    11,    12,    13,
  215.     14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
  216.     24,    25,    -1,    -1,    -1,    -1,    -1,    31,    10,    11,
  217.     12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
  218.     22,    23,    24,    25,    -1,    -1,    -1,    -1,    -1,    31,
  219.     12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
  220.     22,    23,    24,    25,    -1,    -1,    -1,    -1,    -1,    31,
  221.     13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
  222.     23,    24,    25,    -1,    -1,    -1,    -1,    -1,    31,    15,
  223.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  224.     -1,    -1,    -1,    -1,    -1,    31,    19,    20,    21,    22,
  225.     23,    24,    25,    21,    22,    23,    24,    25,    31,    23,
  226.     24,    25,    -1,    31,    -1,    -1,    -1,    31
  227. };
  228. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  229. #line 3 "bison.simple"
  230.  
  231. /* Skeleton output parser for bison,
  232.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  233.  
  234.    This program is free software; you can redistribute it and/or modify
  235.    it under the terms of the GNU General Public License as published by
  236.    the Free Software Foundation; either version 1, or (at your option)
  237.    any later version.
  238.  
  239.    This program is distributed in the hope that it will be useful,
  240.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  241.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  242.    GNU General Public License for more details.
  243.  
  244.    You should have received a copy of the GNU General Public License
  245.    along with this program; if not, write to the Free Software
  246.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  247.  
  248.  
  249. #ifndef alloca
  250. #ifdef __GNUC__
  251. #define alloca __builtin_alloca
  252. #else /* Not GNU C.  */
  253. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  254. #include <alloca.h>
  255. #else /* Not sparc */
  256. #ifdef MSDOS
  257. #include <malloc.h>
  258. #endif /* MSDOS */
  259. #endif /* Not sparc.  */
  260. #endif /* Not GNU C.  */
  261. #endif /* alloca not defined.  */
  262.  
  263. /* This is the parser code that is written into each bison parser
  264.   when the %semantic_parser declaration is not specified in the grammar.
  265.   It was written by Richard Stallman by simplifying the hairy parser
  266.   used when %semantic_parser is specified.  */
  267.  
  268. /* Note: there must be only one dollar sign in this file.
  269.    It is replaced by the list of actions, each action
  270.    as one case of the switch.  */
  271.  
  272. #define yyerrok        (yyerrstatus = 0)
  273. #define yyclearin    (yychar = YYEMPTY)
  274. #define YYEMPTY        -2
  275. #define YYEOF        0
  276. #define YYACCEPT    return(0)
  277. #define YYABORT     return(1)
  278. #define YYERROR        goto yyerrlab1
  279. /* Like YYERROR except do call yyerror.
  280.    This remains here temporarily to ease the
  281.    transition to the new meaning of YYERROR, for GCC.
  282.    Once GCC version 2 has supplanted version 1, this can go.  */
  283. #define YYFAIL        goto yyerrlab
  284. #define YYRECOVERING()  (!!yyerrstatus)
  285. #define YYBACKUP(token, value) \
  286. do                                \
  287.   if (yychar == YYEMPTY && yylen == 1)                \
  288.     { yychar = (token), yylval = (value);            \
  289.       yychar1 = YYTRANSLATE (yychar);                \
  290.       YYPOPSTACK;                        \
  291.       goto yybackup;                        \
  292.     }                                \
  293.   else                                \
  294.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  295. while (0)
  296.  
  297. #define YYTERROR    1
  298. #define YYERRCODE    256
  299.  
  300. #ifndef YYPURE
  301. #define YYLEX        yylex()
  302. #endif
  303.  
  304. #ifdef YYPURE
  305. #ifdef YYLSP_NEEDED
  306. #define YYLEX        yylex(&yylval, &yylloc)
  307. #else
  308. #define YYLEX        yylex(&yylval)
  309. #endif
  310. #endif
  311.  
  312. /* If nonreentrant, generate the variables here */
  313.  
  314. #ifndef YYPURE
  315.  
  316. int    yychar;            /*  the lookahead symbol        */
  317. YYSTYPE    yylval;            /*  the semantic value of the        */
  318.                 /*  lookahead symbol            */
  319.  
  320. #ifdef YYLSP_NEEDED
  321. YYLTYPE yylloc;            /*  location data for the lookahead    */
  322.                 /*  symbol                */
  323. #endif
  324.  
  325. int yynerrs;            /*  number of parse errors so far       */
  326. #endif  /* not YYPURE */
  327.  
  328. #if YYDEBUG != 0
  329. int yydebug;            /*  nonzero means print parse trace    */
  330. /* Since this is uninitialized, it does not stop multiple parsers
  331.    from coexisting.  */
  332. #endif
  333.  
  334. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  335.  
  336. #ifndef    YYINITDEPTH
  337. #define YYINITDEPTH 200
  338. #endif
  339.  
  340. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  341.     (effective only if the built-in stack extension method is used).  */
  342.  
  343. #if YYMAXDEPTH == 0
  344. #undef YYMAXDEPTH
  345. #endif
  346.  
  347. #ifndef YYMAXDEPTH
  348. #define YYMAXDEPTH 10000
  349. #endif
  350.  
  351. #ifndef __cplusplus
  352.  
  353. /* This is the most reliable way to avoid incompatibilities
  354.    in available built-in functions on various systems.  */
  355. static void
  356. __yy_bcopy (from, to, count)
  357.      char *from;
  358.      char *to;
  359.      int count;
  360. {
  361.   register char *f = from;
  362.   register char *t = to;
  363.   register int i = count;
  364.  
  365.   while (i-- > 0)
  366.     *t++ = *f++;
  367. }
  368.  
  369. #else /* __cplusplus */
  370.  
  371. /* This is the most reliable way to avoid incompatibilities
  372.    in available built-in functions on various systems.  */
  373. static void
  374. __yy_bcopy (char *from, char *to, int count)
  375. {
  376.   register char *f = from;
  377.   register char *t = to;
  378.   register int i = count;
  379.  
  380.   while (i-- > 0)
  381.     *t++ = *f++;
  382. }
  383.  
  384. #endif
  385.  
  386. #line 160 "bison.simple"
  387. int
  388. yyparse()
  389. {
  390.   register int yystate;
  391.   register int yyn;
  392.   register short *yyssp;
  393.   register YYSTYPE *yyvsp;
  394.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  395.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  396.  
  397.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  398.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  399.  
  400.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  401.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  402.  
  403. #ifdef YYLSP_NEEDED
  404.   YYLTYPE *yyls = yylsa;
  405.   YYLTYPE *yylsp;
  406.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  407.  
  408. #define YYPOPSTACK   (yyvsp--, yysp--, yylsp--)
  409. #else
  410. #define YYPOPSTACK   (yyvsp--, yysp--)
  411. #endif
  412.  
  413.   int yystacksize = YYINITDEPTH;
  414.  
  415. #ifdef YYPURE
  416.   int yychar;
  417.   YYSTYPE yylval;
  418.   int yynerrs;
  419. #ifdef YYLSP_NEEDED
  420.   YYLTYPE yylloc;
  421. #endif
  422. #endif
  423.  
  424.   YYSTYPE yyval;        /*  the variable used to return        */
  425.                 /*  semantic values from the action    */
  426.                 /*  routines                */
  427.  
  428.   int yylen;
  429.  
  430. #if YYDEBUG != 0
  431.   if (yydebug)
  432.     fprintf(stderr, "Starting parse\n");
  433. #endif
  434.  
  435.   yystate = 0;
  436.   yyerrstatus = 0;
  437.   yynerrs = 0;
  438.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  439.  
  440.   /* Initialize stack pointers.
  441.      Waste one element of value and location stack
  442.      so that they stay on the same level as the state stack.  */
  443.  
  444.   yyssp = yyss - 1;
  445.   yyvsp = yyvs;
  446. #ifdef YYLSP_NEEDED
  447.   yylsp = yyls;
  448. #endif
  449.  
  450. /* Push a new state, which is found in  yystate  .  */
  451. /* In all cases, when you get here, the value and location stacks
  452.    have just been pushed. so pushing a state here evens the stacks.  */
  453. yynewstate:
  454.  
  455.   *++yyssp = yystate;
  456.  
  457.   if (yyssp >= yyss + yystacksize - 1)
  458.     {
  459.       /* Give user a chance to reallocate the stack */
  460.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  461.       YYSTYPE *yyvs1 = yyvs;
  462.       short *yyss1 = yyss;
  463. #ifdef YYLSP_NEEDED
  464.       YYLTYPE *yyls1 = yyls;
  465. #endif
  466.  
  467.       /* Get the current used size of the three stacks, in elements.  */
  468.       int size = yyssp - yyss + 1;
  469.  
  470. #ifdef yyoverflow
  471.       /* Each stack pointer address is followed by the size of
  472.      the data in use in that stack, in bytes.  */
  473.       yyoverflow("parser stack overflow",
  474.          &yyss1, size * sizeof (*yyssp),
  475.          &yyvs1, size * sizeof (*yyvsp),
  476. #ifdef YYLSP_NEEDED
  477.          &yyls1, size * sizeof (*yylsp),
  478. #endif
  479.          &yystacksize);
  480.  
  481.       yyss = yyss1; yyvs = yyvs1;
  482. #ifdef YYLSP_NEEDED
  483.       yyls = yyls1;
  484. #endif
  485. #else /* no yyoverflow */
  486.       /* Extend the stack our own way.  */
  487.       if (yystacksize >= YYMAXDEPTH)
  488.     {
  489.       yyerror("parser stack overflow");
  490.       return 2;
  491.     }
  492.       yystacksize *= 2;
  493.       if (yystacksize > YYMAXDEPTH)
  494.     yystacksize = YYMAXDEPTH;
  495.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  496.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  497.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  498.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  499. #ifdef YYLSP_NEEDED
  500.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  501.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  502. #endif
  503. #endif /* no yyoverflow */
  504.  
  505.       yyssp = yyss + size - 1;
  506.       yyvsp = yyvs + size - 1;
  507. #ifdef YYLSP_NEEDED
  508.       yylsp = yyls + size - 1;
  509. #endif
  510.  
  511. #if YYDEBUG != 0
  512.       if (yydebug)
  513.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  514. #endif
  515.  
  516.       if (yyssp >= yyss + yystacksize - 1)
  517.     YYABORT;
  518.     }
  519.  
  520. #if YYDEBUG != 0
  521.   if (yydebug)
  522.     fprintf(stderr, "Entering state %d\n", yystate);
  523. #endif
  524.  
  525.  yybackup:
  526.  
  527. /* Do appropriate processing given the current state.  */
  528. /* Read a lookahead token if we need one and don't already have one.  */
  529. /* yyresume: */
  530.  
  531.   /* First try to decide what to do without reference to lookahead token.  */
  532.  
  533.   yyn = yypact[yystate];
  534.   if (yyn == YYFLAG)
  535.     goto yydefault;
  536.  
  537.   /* Not known => get a lookahead token if don't already have one.  */
  538.  
  539.   /* yychar is either YYEMPTY or YYEOF
  540.      or a valid token in external form.  */
  541.  
  542.   if (yychar == YYEMPTY)
  543.     {
  544. #if YYDEBUG != 0
  545.       if (yydebug)
  546.     fprintf(stderr, "Reading a token: ");
  547. #endif
  548.       yychar = YYLEX;
  549.     }
  550.  
  551.   /* Convert token to internal form (in yychar1) for indexing tables with */
  552.  
  553.   if (yychar <= 0)        /* This means end of input. */
  554.     {
  555.       yychar1 = 0;
  556.       yychar = YYEOF;        /* Don't call YYLEX any more */
  557.  
  558. #if YYDEBUG != 0
  559.       if (yydebug)
  560.     fprintf(stderr, "Now at end of input.\n");
  561. #endif
  562.     }
  563.   else
  564.     {
  565.       yychar1 = YYTRANSLATE(yychar);
  566.  
  567. #if YYDEBUG != 0
  568.       if (yydebug)
  569.     fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  570. #endif
  571.     }
  572.  
  573.   yyn += yychar1;
  574.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  575.     goto yydefault;
  576.  
  577.   yyn = yytable[yyn];
  578.  
  579.   /* yyn is what to do for this token type in this state.
  580.      Negative => reduce, -yyn is rule number.
  581.      Positive => shift, yyn is new state.
  582.        New state is final state => don't bother to shift,
  583.        just return success.
  584.      0, or most negative number => error.  */
  585.  
  586.   if (yyn < 0)
  587.     {
  588.       if (yyn == YYFLAG)
  589.     goto yyerrlab;
  590.       yyn = -yyn;
  591.       goto yyreduce;
  592.     }
  593.   else if (yyn == 0)
  594.     goto yyerrlab;
  595.  
  596.   if (yyn == YYFINAL)
  597.     YYACCEPT;
  598.  
  599.   /* Shift the lookahead token.  */
  600.  
  601. #if YYDEBUG != 0
  602.   if (yydebug)
  603.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  604. #endif
  605.  
  606.   /* Discard the token being shifted unless it is eof.  */
  607.   if (yychar != YYEOF)
  608.     yychar = YYEMPTY;
  609.  
  610.   *++yyvsp = yylval;
  611. #ifdef YYLSP_NEEDED
  612.   *++yylsp = yylloc;
  613. #endif
  614.  
  615.   /* count tokens shifted since error; after three, turn off error status.  */
  616.   if (yyerrstatus) yyerrstatus--;
  617.  
  618.   yystate = yyn;
  619.   goto yynewstate;
  620.  
  621. /* Do the default action for the current state.  */
  622. yydefault:
  623.  
  624.   yyn = yydefact[yystate];
  625.   if (yyn == 0)
  626.     goto yyerrlab;
  627.  
  628. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  629. yyreduce:
  630.   yylen = yyr2[yyn];
  631.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  632.  
  633. #if YYDEBUG != 0
  634.   if (yydebug)
  635.     {
  636.       int i;
  637.  
  638.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  639.            yyn, yyrline[yyn]);
  640.  
  641.       /* Print the symboles being reduced, and their result.  */
  642.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  643.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  644.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  645.     }
  646. #endif
  647.  
  648.  
  649.   switch (yyn) {
  650.  
  651. case 1:
  652. #line 141 "cexp.y"
  653. { expression_value = yyvsp[0].lval; ;
  654.     break;}
  655. case 3:
  656. #line 147 "cexp.y"
  657. { yyval.lval = yyvsp[0].lval; ;
  658.     break;}
  659. case 4:
  660. #line 152 "cexp.y"
  661. { yyval.lval = - yyvsp[0].lval; ;
  662.     break;}
  663. case 5:
  664. #line 154 "cexp.y"
  665. { yyval.lval = ! yyvsp[0].lval; ;
  666.     break;}
  667. case 6:
  668. #line 156 "cexp.y"
  669. { yyval.lval = ~ yyvsp[0].lval; ;
  670.     break;}
  671. case 7:
  672. #line 158 "cexp.y"
  673. { yyval.lval = yyvsp[-1].lval; ;
  674.     break;}
  675. case 8:
  676. #line 163 "cexp.y"
  677. { yyval.lval = yyvsp[-2].lval * yyvsp[0].lval; ;
  678.     break;}
  679. case 9:
  680. #line 165 "cexp.y"
  681. { yyval.lval = yyvsp[-2].lval / yyvsp[0].lval; ;
  682.     break;}
  683. case 10:
  684. #line 167 "cexp.y"
  685. { yyval.lval = yyvsp[-2].lval % yyvsp[0].lval; ;
  686.     break;}
  687. case 11:
  688. #line 169 "cexp.y"
  689. { yyval.lval = yyvsp[-2].lval + yyvsp[0].lval; ;
  690.     break;}
  691. case 12:
  692. #line 171 "cexp.y"
  693. { yyval.lval = yyvsp[-2].lval - yyvsp[0].lval; ;
  694.     break;}
  695. case 13:
  696. #line 173 "cexp.y"
  697. { yyval.lval = yyvsp[-2].lval << yyvsp[0].lval; ;
  698.     break;}
  699. case 14:
  700. #line 175 "cexp.y"
  701. { yyval.lval = yyvsp[-2].lval >> yyvsp[0].lval; ;
  702.     break;}
  703. case 15:
  704. #line 177 "cexp.y"
  705. { yyval.lval = (yyvsp[-2].lval == yyvsp[0].lval); ;
  706.     break;}
  707. case 16:
  708. #line 179 "cexp.y"
  709. { yyval.lval = (yyvsp[-2].lval != yyvsp[0].lval); ;
  710.     break;}
  711. case 17:
  712. #line 181 "cexp.y"
  713. { yyval.lval = (yyvsp[-2].lval <= yyvsp[0].lval); ;
  714.     break;}
  715. case 18:
  716. #line 183 "cexp.y"
  717. { yyval.lval = (yyvsp[-2].lval >= yyvsp[0].lval); ;
  718.     break;}
  719. case 19:
  720. #line 185 "cexp.y"
  721. { yyval.lval = (yyvsp[-2].lval < yyvsp[0].lval); ;
  722.     break;}
  723. case 20:
  724. #line 187 "cexp.y"
  725. { yyval.lval = (yyvsp[-2].lval > yyvsp[0].lval); ;
  726.     break;}
  727. case 21:
  728. #line 189 "cexp.y"
  729. { yyval.lval = (yyvsp[-2].lval & yyvsp[0].lval); ;
  730.     break;}
  731. case 22:
  732. #line 191 "cexp.y"
  733. { yyval.lval = (yyvsp[-2].lval ^ yyvsp[0].lval); ;
  734.     break;}
  735. case 23:
  736. #line 193 "cexp.y"
  737. { yyval.lval = (yyvsp[-2].lval | yyvsp[0].lval); ;
  738.     break;}
  739. case 24:
  740. #line 195 "cexp.y"
  741. { yyval.lval = (yyvsp[-2].lval && yyvsp[0].lval); ;
  742.     break;}
  743. case 25:
  744. #line 197 "cexp.y"
  745. { yyval.lval = (yyvsp[-2].lval || yyvsp[0].lval); ;
  746.     break;}
  747. case 26:
  748. #line 199 "cexp.y"
  749. { yyval.lval = yyvsp[-4].lval ? yyvsp[-2].lval : yyvsp[0].lval; ;
  750.     break;}
  751. case 27:
  752. #line 201 "cexp.y"
  753. { yyval.lval = yylval.lval; ;
  754.     break;}
  755. case 28:
  756. #line 203 "cexp.y"
  757. { yyval.lval = yylval.lval; ;
  758.     break;}
  759. case 29:
  760. #line 205 "cexp.y"
  761. { yyval.lval = 0; ;
  762.     break;}
  763. }
  764.    /* the action file gets copied in in place of this dollarsign */
  765. #line 423 "bison.simple"
  766.  
  767.   yyvsp -= yylen;
  768.   yyssp -= yylen;
  769. #ifdef YYLSP_NEEDED
  770.   yylsp -= yylen;
  771. #endif
  772.  
  773. #if YYDEBUG != 0
  774.   if (yydebug)
  775.     {
  776.       short *ssp1 = yyss - 1;
  777.       fprintf (stderr, "state stack now");
  778.       while (ssp1 != yyssp)
  779.     fprintf (stderr, " %d", *++ssp1);
  780.       fprintf (stderr, "\n");
  781.     }
  782. #endif
  783.  
  784.   *++yyvsp = yyval;
  785.  
  786. #ifdef YYLSP_NEEDED
  787.   yylsp++;
  788.   if (yylen == 0)
  789.     {
  790.       yylsp->first_line = yylloc.first_line;
  791.       yylsp->first_column = yylloc.first_column;
  792.       yylsp->last_line = (yylsp-1)->last_line;
  793.       yylsp->last_column = (yylsp-1)->last_column;
  794.       yylsp->text = 0;
  795.     }
  796.   else
  797.     {
  798.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  799.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  800.     }
  801. #endif
  802.  
  803.   /* Now "shift" the result of the reduction.
  804.      Determine what state that goes to,
  805.      based on the state we popped back to
  806.      and the rule number reduced by.  */
  807.  
  808.   yyn = yyr1[yyn];
  809.  
  810.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  811.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  812.     yystate = yytable[yystate];
  813.   else
  814.     yystate = yydefgoto[yyn - YYNTBASE];
  815.  
  816.   goto yynewstate;
  817.  
  818. yyerrlab:   /* here on detecting error */
  819.  
  820.   if (! yyerrstatus)
  821.     /* If not already recovering from an error, report this error.  */
  822.     {
  823.       ++yynerrs;
  824.  
  825. #ifdef YYERROR_VERBOSE
  826.       yyn = yypact[yystate];
  827.  
  828.       if (yyn > YYFLAG && yyn < YYLAST)
  829.     {
  830.       int size = 0;
  831.       char *msg;
  832.       int x, count;
  833.  
  834.       count = 0;
  835.       for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  836.         if (yycheck[x + yyn] == x)
  837.           size += strlen(yytname[x]) + 15, count++;
  838.       msg = (char *) xmalloc(size + 15);
  839.       strcpy(msg, "parse error");
  840.  
  841.       if (count < 5)
  842.         {
  843.           count = 0;
  844.           for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  845.         if (yycheck[x + yyn] == x)
  846.           {
  847.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  848.             strcat(msg, yytname[x]);
  849.             strcat(msg, "'");
  850.             count++;
  851.           }
  852.         }
  853.       yyerror(msg);
  854.       free(msg);
  855.     }
  856.       else
  857. #endif /* YYERROR_VERBOSE */
  858.     yyerror("parse error");
  859.     }
  860.  
  861. yyerrlab1:   /* here on error raised explicitly by an action */
  862.  
  863.   if (yyerrstatus == 3)
  864.     {
  865.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  866.  
  867.       /* return failure if at end of input */
  868.       if (yychar == YYEOF)
  869.     YYABORT;
  870.  
  871. #if YYDEBUG != 0
  872.       if (yydebug)
  873.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  874. #endif
  875.  
  876.       yychar = YYEMPTY;
  877.     }
  878.  
  879.   /* Else will try to reuse lookahead token
  880.      after shifting the error token.  */
  881.  
  882.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  883.  
  884.   goto yyerrhandle;
  885.  
  886. yyerrdefault:  /* current state does not do anything special for the error token. */
  887.  
  888. #if 0
  889.   /* This is wrong; only states that explicitly want error tokens
  890.      should shift them.  */
  891.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  892.   if (yyn) goto yydefault;
  893. #endif
  894.  
  895. yyerrpop:   /* pop the current state because it cannot handle the error token */
  896.  
  897.   if (yyssp == yyss) YYABORT;
  898.   yyvsp--;
  899.   yystate = *--yyssp;
  900. #ifdef YYLSP_NEEDED
  901.   yylsp--;
  902. #endif
  903.  
  904. #if YYDEBUG != 0
  905.   if (yydebug)
  906.     {
  907.       short *ssp1 = yyss - 1;
  908.       fprintf (stderr, "Error: state stack now");
  909.       while (ssp1 != yyssp)
  910.     fprintf (stderr, " %d", *++ssp1);
  911.       fprintf (stderr, "\n");
  912.     }
  913. #endif
  914.  
  915. yyerrhandle:
  916.  
  917.   yyn = yypact[yystate];
  918.   if (yyn == YYFLAG)
  919.     goto yyerrdefault;
  920.  
  921.   yyn += YYTERROR;
  922.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  923.     goto yyerrdefault;
  924.  
  925.   yyn = yytable[yyn];
  926.   if (yyn < 0)
  927.     {
  928.       if (yyn == YYFLAG)
  929.     goto yyerrpop;
  930.       yyn = -yyn;
  931.       goto yyreduce;
  932.     }
  933.   else if (yyn == 0)
  934.     goto yyerrpop;
  935.  
  936.   if (yyn == YYFINAL)
  937.     YYACCEPT;
  938.  
  939. #if YYDEBUG != 0
  940.   if (yydebug)
  941.     fprintf(stderr, "Shifting error token, ");
  942. #endif
  943.  
  944.   *++yyvsp = yylval;
  945. #ifdef YYLSP_NEEDED
  946.   *++yylsp = yylloc;
  947. #endif
  948.  
  949.   yystate = yyn;
  950.   goto yynewstate;
  951. }
  952. #line 207 "cexp.y"
  953.  
  954.  
  955. /* During parsing of a C expression, the pointer to the next character
  956.    is in this variable.  */
  957.  
  958. static char *lexptr;
  959.  
  960. /* Take care of parsing a number (anything that starts with a digit).
  961.    Set yylval and return the token type; update lexptr.
  962.    LEN is the number of characters in it.  */
  963.  
  964. /* maybe needs to actually deal with floating point numbers */
  965.  
  966. static int
  967. parse_number (olen)
  968.      int olen;
  969. {
  970.   register char *p = lexptr;
  971.   register long n = 0;
  972.   register int c;
  973.   register int base = 10;
  974.   register len = olen;
  975.   char *err_copy;
  976.  
  977.   extern double atof ();
  978.  
  979.   for (c = 0; c < len; c++)
  980.     if (p[c] == '.') {
  981.       /* It's a float since it contains a point.  */
  982.       yyerror ("floating point numbers not allowed in #if expressions");
  983.       return ERROR;
  984.       
  985. /* ****************
  986.      yylval.dval = atof (p);
  987.      lexptr += len;
  988.      return FLOAT;
  989.          ****************  */
  990.     }
  991.   
  992.   if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) {
  993.     p += 2;
  994.     base = 16;
  995.     len -= 2;
  996.   }
  997.   else if (*p == '0')
  998.     base = 8;
  999.   
  1000.   while (len-- > 0) {
  1001.     c = *p++;
  1002.     n *= base;
  1003.     if (c >= '0' && c <= '9')
  1004.       n += c - '0';
  1005.     else {
  1006.       if (c >= 'A' && c <= 'Z') c += 'a' - 'A';
  1007.       if (base == 16 && c >= 'a' && c <= 'f')
  1008.     n += c - 'a' + 10;
  1009.       else if (len == 0 && c == 'l')
  1010.     ;
  1011.       else {
  1012.     yyerror ("Invalid number in #if expression");
  1013.     return ERROR;
  1014.       }
  1015.     }
  1016.   }
  1017.  
  1018.   lexptr = p;
  1019.   yylval.lval = n;
  1020.   return INT;
  1021. }
  1022.  
  1023. struct token {
  1024.   char *operator;
  1025.   int token;
  1026. };
  1027.  
  1028. #define NULL 0
  1029.  
  1030. static struct token tokentab2[] = {
  1031.   {"&&", AND},
  1032.   {"||", OR},
  1033.   {"<<", LSH},
  1034.   {">>", RSH},
  1035.   {"==", EQUAL},
  1036.   {"!=", NOTEQUAL},
  1037.   {"<=", LEQ},
  1038.   {">=", GEQ},
  1039.   {NULL, ERROR}
  1040. };
  1041.  
  1042. /* Read one token, getting characters through lexptr.  */
  1043.  
  1044. static int
  1045. yylex ()
  1046. {
  1047.   register int c;
  1048.   register int namelen;
  1049.   register char *tokstart;
  1050.   register struct token *toktab;
  1051.  
  1052.  retry:
  1053.  
  1054.   tokstart = lexptr;
  1055.   c = *tokstart;
  1056.   /* See if it is a special token of length 2.  */
  1057.   for (toktab = tokentab2; toktab->operator != NULL; toktab++)
  1058.     if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) {
  1059.       lexptr += 2;
  1060.       return toktab->token;
  1061.     }
  1062.  
  1063.   switch (c) {
  1064.   case 0:
  1065.     return 0;
  1066.     
  1067.   case ' ':
  1068.   case '\t':
  1069.   case '\n':
  1070.     lexptr++;
  1071.     goto retry;
  1072.     
  1073.   case '\'':
  1074.     lexptr++;
  1075.     c = *lexptr++;
  1076.     if (c == '\\')
  1077.       c = parse_escape (&lexptr);
  1078.     yylval.lval = c;
  1079.     c = *lexptr++;
  1080.     if (c != '\'') {
  1081.       yyerror ("Invalid character constant in #if");
  1082.       return ERROR;
  1083.     }
  1084.     
  1085.     return CHAR;
  1086.  
  1087.   case '/':            /* possible comment */
  1088.     if (*lexptr != '*')
  1089.       return c;
  1090.     for (;;) {
  1091.       while (*lexptr != '\0') {
  1092.     if (*lexptr++ == '*' && *lexptr == '/') {
  1093.       lexptr++;
  1094.       goto retry;
  1095.     }
  1096.       }
  1097.     }
  1098.  
  1099.     /* some of these chars are invalid in constant expressions;
  1100.        maybe do something about them later */
  1101.   case '+':
  1102.   case '-':
  1103.   case '*':
  1104.   case '%':
  1105.   case '|':
  1106.   case '&':
  1107.   case '^':
  1108.   case '~':
  1109.   case '!':
  1110.   case '@':
  1111.   case '<':
  1112.   case '>':
  1113.   case '(':
  1114.   case ')':
  1115.   case '[':
  1116.   case ']':
  1117.   case '.':
  1118.   case '?':
  1119.   case ':':
  1120.   case '=':
  1121.   case '{':
  1122.   case '}':
  1123.   case ',':
  1124.     lexptr++;
  1125.     return c;
  1126.     
  1127.   case '"':
  1128.     yyerror ("double quoted strings not allowed in #if expressions");
  1129.     return ERROR;
  1130.   }
  1131.   if (c >= '0' && c <= '9') {
  1132.     /* It's a number */
  1133.     for (namelen = 0;
  1134.      c = tokstart[namelen], is_idchar[c] || c == '.'; 
  1135.      namelen++)
  1136.       ;
  1137.     return parse_number (namelen);
  1138.   }
  1139.   
  1140.   if (!is_idstart[c]) {
  1141.     yyerror ("Invalid token in expression");
  1142.     return ERROR;
  1143.   }
  1144.   
  1145.   /* It is a name.  See how long it is.  */
  1146.   
  1147.   for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++)
  1148.     ;
  1149.   
  1150.   lexptr += namelen;
  1151.   return NAME;
  1152. }
  1153.  
  1154.  
  1155. /* Parse a C escape sequence.  STRING_PTR points to a variable
  1156.    containing a pointer to the string to parse.  That pointer
  1157.    is updated past the characters we use.  The value of the
  1158.    escape sequence is returned.
  1159.  
  1160.    A negative value means the sequence \ newline was seen,
  1161.    which is supposed to be equivalent to nothing at all.
  1162.  
  1163.    If \ is followed by a null character, we return a negative
  1164.    value and leave the string pointer pointing at the null character.
  1165.  
  1166.    If \ is followed by 000, we return 0 and leave the string pointer
  1167.    after the zeros.  A value of 0 does not mean end of string.  */
  1168.  
  1169. static int
  1170. parse_escape (string_ptr)
  1171.      char **string_ptr;
  1172. {
  1173.   register int c = *(*string_ptr)++;
  1174.   switch (c)
  1175.     {
  1176.     case 'a':
  1177.       return '\a';
  1178.     case 'b':
  1179.       return '\b';
  1180.     case 'e':
  1181.       return 033;
  1182.     case 'f':
  1183.       return '\f';
  1184.     case 'n':
  1185.       return '\n';
  1186.     case 'r':
  1187.       return '\r';
  1188.     case 't':
  1189.       return '\t';
  1190.     case 'v':
  1191.       return '\v';
  1192.     case '\n':
  1193.       return -2;
  1194.     case 0:
  1195.       (*string_ptr)--;
  1196.       return 0;
  1197.     case '^':
  1198.       c = *(*string_ptr)++;
  1199.       if (c == '\\')
  1200.     c = parse_escape (string_ptr);
  1201.       if (c == '?')
  1202.     return 0177;
  1203.       return (c & 0200) | (c & 037);
  1204.       
  1205.     case '0':
  1206.     case '1':
  1207.     case '2':
  1208.     case '3':
  1209.     case '4':
  1210.     case '5':
  1211.     case '6':
  1212.     case '7':
  1213.       {
  1214.     register int i = c - '0';
  1215.     register int count = 0;
  1216.     while (++count < 3)
  1217.       {
  1218.         if ((c = *(*string_ptr)++) >= '0' && c <= '7')
  1219.           {
  1220.         i *= 8;
  1221.         i += c - '0';
  1222.           }
  1223.         else
  1224.           {
  1225.         (*string_ptr)--;
  1226.         break;
  1227.           }
  1228.       }
  1229.     return i;
  1230.       }
  1231.     default:
  1232.       return c;
  1233.     }
  1234. }
  1235.  
  1236. static
  1237. yyerror (s)
  1238.      char *s;
  1239. {
  1240.   error (s);
  1241.   longjmp (parse_return_error, 1);
  1242. }
  1243.  
  1244. /* This page contains the entry point to this file.  */
  1245.  
  1246. /* Parse STRING as an expression, and complain if this fails
  1247.    to use up all of the contents of STRING.  */
  1248. int
  1249. parse_c_expression (string)
  1250.      char *string;
  1251. {
  1252.   lexptr = string;
  1253.   
  1254.   if (lexptr == 0 || *lexptr == 0) {
  1255.     error ("empty #if expression");
  1256.     return 0;            /* don't include the #if group */
  1257.   }
  1258.  
  1259.   /* if there is some sort of scanning error, just return 0 and assume
  1260.      the parsing routine has printed an error message somewhere.
  1261.      there is surely a better thing to do than this.     */
  1262.   if (setjmp(parse_return_error))
  1263.     return 0;
  1264.  
  1265.   if (yyparse ())
  1266.     return 0;            /* actually this is never reached
  1267.                    the way things stand. */
  1268.   if (*lexptr)
  1269.     error ("Junk after end of expression.");
  1270.  
  1271.   return expression_value;    /* set by yyparse() */
  1272. }
  1273.  
  1274. #ifdef TEST_EXP_READER
  1275. /* main program, for testing purposes. */
  1276. main()
  1277. {
  1278.   int n;
  1279.   char buf[1024];
  1280.   extern int yydebug;
  1281. /*
  1282.   yydebug = 1;
  1283. */
  1284.   initialize_random_junk ();
  1285.  
  1286.   for (;;) {
  1287.     printf("enter expression: ");
  1288.     n = 0;
  1289.     while ((buf[n] = getchar()) != '\n')
  1290.       n++;
  1291.     buf[n] = '\0';
  1292.     printf("parser returned %d\n", parse_c_expression(buf));
  1293.   }
  1294. }
  1295.  
  1296. /* table to tell if char can be part of a C identifier. */
  1297. char is_idchar[256];
  1298. /* table to tell if char can be first char of a c identifier. */
  1299. char is_idstart[256];
  1300. /* table to tell if c is horizontal space.  isspace() thinks that
  1301.    newline is space; this is not a good idea for this program. */
  1302. char is_hor_space[256];
  1303.  
  1304. /*
  1305.  * initialize random junk in the hash table and maybe other places
  1306.  */
  1307. initialize_random_junk()
  1308. {
  1309.   register int i;
  1310.  
  1311.   /*
  1312.    * Set up is_idchar and is_idstart tables.  These should be
  1313.    * faster than saying (is_alpha(c) || c == '_'), etc.
  1314.    * Must do set up these things before calling any routines tthat
  1315.    * refer to them.
  1316.    */
  1317.   for (i = 'a'; i <= 'z'; i++) {
  1318.     ++is_idchar[i - 'a' + 'A'];
  1319.     ++is_idchar[i];
  1320.     ++is_idstart[i - 'a' + 'A'];
  1321.     ++is_idstart[i];
  1322.   }
  1323.   for (i = '0'; i <= '9'; i++)
  1324.     ++is_idchar[i];
  1325.   ++is_idchar['_'];
  1326.   ++is_idstart['_'];
  1327.  
  1328.   /* horizontal space table */
  1329.   ++is_hor_space[' '];
  1330.   ++is_hor_space['\t'];
  1331. }
  1332.  
  1333. error (msg)
  1334. {
  1335.   printf("error: %s\n", msg);
  1336. }
  1337. #endif
  1338.